package com.tchepannou.limbe.validation;

import com.tchepannou.util.StringUtil;

import java.lang.reflect.Field;

/**
 * User: herve
 * Date: 14-01-12 11:54 AM
 */
public class NullValidator extends AbstractValidator
{
    @Override
    public boolean validate(Object bean, Field field)
    {
        Object value = getValue(bean, field);
        if (value instanceof String)
        {
            return StringUtil.isEmpty((String) value);
        }
        else
        {
            return value == null;
        }
    }

    @Override
    public boolean validate(Object bean)
    {
        return bean == null;
    }
}
